package ciyuan.ChangeMinecraft;

import ciyuan.Block.TypeInterface.Machine;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

/**
 * @author 150149
 */
@Mod.EventBusSubscriber
public class NoBreakHasItemBlock {

    //@SubscribeEvent
    public static void onBlockBreak(BlockEvent.BreakEvent event) {
        if (event.getState().getBlock() instanceof Machine) {
            Machine machine = (Machine) event.getState().getBlock();
            if (machine.hasItem()) {
                event.setCanceled(true);
            }
        }
    }

    @SubscribeEvent
    public static void onBreak(PlayerEvent.BreakSpeed event) {
        if (event.getState().getBlock() instanceof Machine) {
            Machine machine = (Machine) event.getState().getBlock();
            if (machine.hasItem()) {
                event.setCanceled(true);
            }
        }
    }

}
